/*
 * pack.h
 *
 *  Created on: Sep 6, 2020
 *      Author: daniel
 */

#ifndef INC_PACK_H_
#define INC_PACK_H_

#include <stdint.h>
#include <stdbool.h>
#include "LoRA.h"
#include "data_struct.h"

uint8_t packDataAck(const WS_DATA_ACK* data, uint8_t cmd, uint8_t no, uint8_t* buffer, uint8_t buffersize);
uint8_t packFirmwareData(const uint8_t* data, uint8_t dataSize, uint8_t no, uint8_t* buffer, uint8_t bufferSize);

uint8_t unpackData(uint8_t* buffer, uint8_t buffersize, uint8_t* no, uint8_t* sendBuffer);
uint8_t unpackFirmwarePayload(const uint8_t* buffer, uint8_t buffersize);

// 回调函数，在解码后，根据不同请求，回调
uint8_t cmd_Data(const WS_DATA* data, uint8_t no, uint8_t* sendBuffer);
uint8_t cmd_GetFirmware(uint32_t pos, uint8_t no, uint8_t* sendBuffer);

// 在紧急Beacon状态下，返回重启或则固件基本信息
uint8_t cmd_BeaconAck(const WS_LORA_STATUS* data, uint8_t no, uint8_t* sendBuffer);

void payload_aead_init();

#endif /* INC_PACK_H_ */
